<?php
class Press extends AppModel {
	var $name = 'Press';
	var $displayField = 'name';
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'Status' => array(
			'className' => 'Status',
			'foreignKey' => 'status_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'PressMake' => array(
			'className' => 'PressMake',
			'foreignKey' => 'make',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'PressModel' => array(
			'className' => 'PressModel',
			'foreignKey' => 'model',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'PressType' => array(
			'className' => 'PressType',
			'foreignKey' => 'type',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Status' => array(
			'className' => 'Status',
			'foreignKey' => 'status_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'SellType' => array(
			'className' => 'SellType',
			'foreignKey' => 'sell_type_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Country' => array(
			'className' => 'Country',
			'foreignKey' => 'location',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

	var $hasMany = array(
		'Auction' => array(
			'className' => 'Auction',
			'foreignKey' => 'press_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Offer' => array(
			'className' => 'Offer',
			'foreignKey' => 'press_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
	// validate data
	/*var $validate=array(
		'name'=>array(
			'rule' => array('minLength', 2),
			'required' => true
		),
		'offered'=>array(
			'rule' => 'notEmpty',
			'required' => true
		),
		'sup_reference'=>array(
			'rule' => 'notEmpty',
			'required' => true		
		),
		'serial_number'=>array(	
			'rule' => 'notEmpty',		
			'required' => true
		),
		'year'=>array(
			'rule-1'=>array(
				'rule' => 'numeric',		
				'required' => true
			),
			'ruler-2'=>array(
				'rule' => array('maxLength',4),
				'required' => true			
			),
			'rule-3'=>array(
				'rule' => 'notEmpty',
				'required' => true
			)
		),
		'colour'=>array(			
			'rule' => 'notEmpty',	
			'allowEmpty' => false,
		),
		'perfect'=>array(
			'rule' => 'notEmpty',
			'required' => true,		
		),
		'description'=>array(	
			'rule' => 'notEmpty',
			'required' => true
		),
		'paper_size2'=>array(
			'rule'=>array('checkSize'),	
			'required' => true,		
			'allowEmpty' => false
		),
		'buy_price'=>array(
			'rule' => 'numeric',
			'required' => true,
			'allowEmpty' => false
		),
		'sell_price'=>array(
			'rule' => 'numeric',
			'required' => true,
			'allowEmpty' => false
		),
		'available_from_date'=>array(
			'rule' => 'date',
			'required' => true,
			'allowEmpty' => false
		),
		'first_off_date'=>array(
			'rule' => 'date',
			'required' => true,
			'allowEmpty' => false
		),
		'photo1'=>array(
			'rule' => 'notEmpty',
			'required' => true
		)
	);
	function checkSize(){
		$data=$this->data['Press'];
		if(empty($data['paper_size1'])||empty($data['paper_size2']))
			return false;
		if(intval($data['paper_size1'])==0||intval($data['paper_size2'])==0)
			return true;
		return true;
	}*/
}
?>